package com.cenluan.gallery.member;

import com.cenluan.gallery.Gallery;
import com.cenluan.user.User;
import com.jfinal.plugin.activerecord.Model;

/**
 * 相册成员
 * 
 * @author peak
 * 
 */
public class GalleryMember extends Model<GalleryMember> {

	private static final long serialVersionUID = 1L;

	public static final GalleryMember dao = new GalleryMember();

	/**
	 * 获取对应相册
	 * 
	 * @return
	 */
	public Gallery getGallery() {
		return Gallery.dao.findById(getStr("galleryId"));
	}

	/**
	 * 获取对应的用户
	 * 
	 * @return
	 */
	public User getUser() {
		return User.dao.findById(getStr("userId"));
	}

	/**
	 * 依据相册id和用户id查找
	 * 
	 * @param galleryId
	 * @param userId
	 */
	public GalleryMember findBygalleryIdAndUserId(String galleryId,
			String userId) {
		return findFirst("select * from t_gallery_member "
				+ "where galleryId=? and userId=?", galleryId, userId);
	}

}
